package com.citytechinc.cmis.client.service
{
	import com.citytechinc.cmis.client.model.Property;
	import com.citytechinc.cmis.client.model.Repository;
	
	import flexunit.framework.TestCase;
	
	public class RepositoryInfoServiceTest extends TestCase
	{
		private namespace app = "http://www.w3.org/2007/app";
		private namespace atom = "http://www.w3.org/2005/Atom";
		private namespace cmis = "http://docs.oasis-open.org/ns/cmis/core/200901";
		
		use namespace app;
        use namespace atom;
        use namespace cmis;
        
		private static const repoInfo:XML = 
			<service xmlns="http://www.w3.org/2007/app" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200901">
				<workspace>
					<atom:title type="text">CMIS Repository</atom:title>
					<cmis:repositoryInfo>
						<cmis:repositoryId>repid1</cmis:repositoryId>
						<cmis:repositoryName>Repository1</cmis:repositoryName>
						<cmis:repositoryRelationship>self</cmis:repositoryRelationship>
						<cmis:repositoryDescription>CMIS Repository Description</cmis:repositoryDescription>
						<cmis:vendorName>CMIS Vendor 1</cmis:vendorName>
						<cmis:productName>CMIS Prototype for VendorX</cmis:productName>
						<cmis:productVersion>0.61</cmis:productVersion>
						<cmis:rootFolderId>rootfolder</cmis:rootFolderId>
						<cmis:capabilities>
							<cmis:capabilityMultifiling>true</cmis:capabilityMultifiling>
							<cmis:capabilityUnfiling>true</cmis:capabilityUnfiling>
							<cmis:capabilityVersionSpecificFiling>true</cmis:capabilityVersionSpecificFiling>
							<cmis:capabilityPWCUpdateable>true</cmis:capabilityPWCUpdateable>
							<cmis:capabilityPWCSearchable>true</cmis:capabilityPWCSearchable>
							<cmis:capabilityAllVersionsSearchable>true</cmis:capabilityAllVersionsSearchable>
							<cmis:capabilityQuery>bothcombined</cmis:capabilityQuery>
							<cmis:capabilityJoin>innerandouter</cmis:capabilityJoin>
							<cmis:capabilityChanges>includeDocuments</cmis:capabilityChanges>
							<cmis:capabilityChanges>includeFolders</cmis:capabilityChanges>
							<cmis:capabilityChanges>includeRelationships</cmis:capabilityChanges>
							<cmis:capabilityChanges>includeProperties</cmis:capabilityChanges>
							<cmis:capabilityChanges>includeACL</cmis:capabilityChanges>
							<cmis:changesIncomplete>true</cmis:changesIncomplete>
						</cmis:capabilities>
						<cmis:cmisVersionSupported>0.61</cmis:cmisVersionSupported>
					</cmis:repositoryInfo>
					<collection href="http://cmisexample.oasis-open.org/rep1//checkedout" cmis:collectionType="checkedout">
						<atom:title type="text">Checkedout collection</atom:title>
						<accept>application/atom+xml;type=entry</accept>
					</collection>
					<collection href="http://cmisexample.oasis-open.org/rep1//query" cmis:collectionType="query">
						<atom:title type="text">Query collection</atom:title>
						<accept>application/cmisquery+xml</accept>
					</collection>
					<collection href="http://cmisexample.oasis-open.org/rep1//rootc" cmis:collectionType="rootchildren">
						<atom:title type="text">Root children collection</atom:title>
					</collection>
					<collection href="http://cmisexample.oasis-open.org/rep1//rootd" cmis:collectionType="rootdescendants">
						<atom:title type="text">Root descendants collection</atom:title>
					</collection>
					<collection href="http://cmisexample.oasis-open.org/rep1//typec" cmis:collectionType="typeschildren">
						<atom:title type="text">Types children collection</atom:title>
					</collection>
					<collection href="http://cmisexample.oasis-open.org/rep1//typed" cmis:collectionType="typesdescendants">
						<atom:title type="text">Types descendants collection</atom:title>
					</collection>
					<collection href="http://cmisexample.oasis-open.org/rep1//unfiled" cmis:collectionType="unfiled">
						<atom:title type="text">Unfiled collection</atom:title>
						<accept>application/atom+xml;type=entry</accept>
					</collection>
					<collection href="http://cmisexample.oasis-open.org/rep1//changes" cmis:collectionType="changes">
						<atom:title type="text">changes collection</atom:title>
					</collection>
				</workspace>
			</service>;
			
		private var repository:Repository;
			
		public function RepositoryInfoServiceTest()
		{
			var repoInfoService:RepositoryInfoService = new RepositoryInfoService("");
			
			repository = repoInfoService.getRepositoryInfo(repoInfo);
		}
		
		public function testChildrenURL():void 
		{
			assertEquals(repository.childrenURL, repoInfo.workspace.collection.(@collectionType=='rootchildren').@href);
   		}
   		
		public function testQueryURL():void 
		{
   			assertEquals(repository.queryURL, repoInfo.workspace.collection.(@collectionType=='query').@href);
   		}
   	
		public function testTypesURL():void 
		{
   			assertEquals(repository.typesURL, repoInfo.workspace.collection.(@collectionType=='typesdescendants').@href);
   		}
   		
   		public function testProperties():void 
   		{
   			for each (var prop:Property in repository.properties)
   				assertEquals(repoInfo.workspace.repositoryInfo[prop.name], prop.value);		
   		}
   		
   		public function testCapabilities():void 
   		{
   			for each (var cap:Property in repository.capabilities)
   				assertEquals(repoInfo.workspace.repositoryInfo.capabilities[cap.name], cap.value);		
   		}

	}
	
}